home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / include / ntfs / debug.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-18  |  2.8 KB  |  90 lines

  1. /*
  2.  * debug.h - Debugging output functions. Part of the Linux-NTFS project.
  3.  *
  4.  * Copyright (c) 2002-2004 Anton Altaparmakov
  5.  *
  6.  * This program/include file is free software; you can redistribute it and/or
  7.  * modify it under the terms of the GNU General Public License as published
  8.  * by the Free Software Foundation; either version 2 of the License, or
  9.  * (at your option) any later version.
  10.  *
  11.  * This program/include file is distributed in the hope that it will be
  12.  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  13.  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program (in the main directory of the Linux-NTFS
  18.  * distribution in the file COPYING); if not, write to the Free Software
  19.  * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  20.  */
  21.  
  22. #ifndef _NTFS_DEBUG_H
  23. #define _NTFS_DEBUG_H
  24.  
  25. #ifdef HAVE_CONFIG_H
  26. #include "config.h"
  27. #endif
  28. #ifdef HAVE_STDIO_H
  29. #    include <stdio.h>
  30. #endif
  31. #ifdef HAVE_STDARG_H
  32. #    include <stdarg.h>
  33. #endif
  34. #include <string.h>
  35. #include <errno.h>
  36.  
  37. struct _runlist_element;
  38.  
  39. extern void __Sprintf(const int silent, const char *fmt, ...)
  40.         __attribute__ ((format (printf, 2, 3)));
  41. #define Sprintf(silent, f, a...)    __Sprintf(silent, f, ##a)
  42.  
  43. #ifdef DEBUG
  44.  
  45. /* Debug output to stderr.  To get it run ./configure --enable-debug. */
  46.  
  47. extern void __ntfs_debug (const char *file, int line, const char *function,
  48.         const char *format, ...) __attribute__((format(printf, 4, 5)));
  49. #define ntfs_debug(f, a...)                        \
  50.         __ntfs_debug(__FILE__, __LINE__, __FUNCTION__, f, ##a)
  51.  
  52. extern void __ntfs_error(const char *function,
  53.         const char *fmt, ...) __attribute__((format(printf, 2, 3)));
  54. #define ntfs_error(sb, f, a...)        __ntfs_error(__FUNCTION__, f, ##a)
  55.  
  56. extern void __Dprintf(const char *fmt, ...)
  57.         __attribute__ ((format (printf, 1, 2)));
  58. #define Dprintf(f, a...)    __Dprintf(f, ##a)
  59.  
  60. extern void __Dputs(const char *s);
  61. #define Dputs(s)        __Dputs(s)
  62.  
  63. extern void __Dperror(const char *s);
  64. #define Dperror(s)        __Dperror(s)
  65.  
  66. extern void ntfs_debug_runlist_dump(const struct _runlist_element *rl);
  67.  
  68. #else /* if !DEBUG */
  69.  
  70. #define ntfs_debug(f, a...)        do {} while (0)
  71. #define ntfs_error(f, a...)        do {} while (0)
  72.  
  73. #define Dprintf(f, a...)    do {} while (0)
  74. #define Dputs(s)        do {} while (0)
  75. #define Dperror(s)        do {} while (0)
  76.  
  77. static __inline__ void ntfs_debug_runlist_dump(const struct _runlist_element *rl __attribute__((unused))) {}
  78.  
  79. #endif /* !DEBUG */
  80.  
  81. #define NTFS_BUG(msg)                              \
  82. {                                      \
  83.     int ___i;                              \
  84.     fprintf(stderr, "libntfs: Bug in %s(): %s\n", __FUNCTION__, msg); \
  85.     Dputs("Forcing segmentation fault!");                  \
  86.     ___i = ((int*)NULL)[1];                          \
  87. }
  88.  
  89. #endif /* defined _NTFS_DEBUG_H */
  90.